#include "levelchoose.h"
#include <QPushButton>
#include <QMenuBar>
#include <QLineEdit>
#include <QDebug>
#include <QLabel>
#include <alwindow.h>
#include "helper.h"
#include <qfont.h>
#include <writer.h>
#include "mainwindow.h"
levelchoose::levelchoose(QWidget *parent) : QMainWindow(parent)
{
    this->setWindowTitle("选择难度");
    QMenuBar * bar = menuBar();
    setMenuBar(bar);
    QFont Menu_font("Microsoft YaHei",12, 75);
    bar->setFont(Menu_font);
    QMenu * startMenu = bar->addMenu("· · ·");


    QAction * help = startMenu->addAction("帮助");
    connect(help,&QAction::triggered,[=](){
        helper * helplist = new helper;
        helplist -> show();
    });
    QAction * back = startMenu->addAction("返回");
    connect(back,&QAction::triggered,[=](){
        this->close();
        MainWindow * window = new MainWindow();
        window->show();
    });

    QAction * quit = startMenu->addAction("退出");
    connect(quit,&QAction::triggered,[=](){
        this->close();
    });
    startMenu -> addSeparator();
    QAction * shiki = startMenu->addAction("ovo");
    connect(shiki,&QAction::triggered,[=](){
        writer * W = new writer;
        W->show();
    });
    //↑菜单栏
    this->setFixedSize(800,600);

    QPushButton * easy = new QPushButton("简单",this);
    easy->resize(300,100);
    easy->move(this->width()*0.5-easy->width()*1,this->height()*0.15);
    connect(easy,&QPushButton::clicked,[=](){
        len = 9;wid = 9;num = 10;
        gamescene = new game(nullptr,len,wid,num);
        this->hide();
        gamescene->show();
        });
    QPushButton * medium = new QPushButton("中等",this);
    medium->resize(300,100);
    medium->move(this->width()*0.5-medium->width()*1,this->height()*0.35);
    connect(medium,&QPushButton::clicked,[=](){
        len = 16;wid = 16;num = 40;
        gamescene = new game(nullptr,len,wid,num);
        this->hide();
        gamescene->show();
        });
    QPushButton * hard = new QPushButton("困难",this);
    hard->resize(300,100);
    hard->move(this->width()*0.5-hard->width()*1,this->height()*0.55);
    connect(hard,&QPushButton::clicked,[=](){
        len = 30;wid = 16;num = 99;
        gamescene = new game(nullptr,len,wid,num);
        this->hide();
        gamescene->show();
        });
    alwindow * op = new alwindow;
    QPushButton * customize = new QPushButton("自定义",this);
    customize->resize(300,100);
    customize->move(this->width()*0.5-customize->width()*1,this->height()*0.75);
    connect(op,&alwindow::levelsceneBack,this,[=](){
        emit this-> levelsceneBack();
        op->close();
    });
    connect(customize,&QPushButton::clicked,[=](){
        op -> show();
    });
    connect(op,&alwindow::finished,this, [=](){
        gamescene = new game(nullptr,op->length,op->width,op->num);
        op->close();
        this->hide();
        gamescene->show();
    });


}
